package com.huai.demo_test1.test1;public class TestVolaile {    public volatile int inc = 0;    public void increase() {        inc++;    }    public static void main(String[] args) {        final TestVolaile test = new TestVolaile();        for (int i = 0; i < 10; i++) {            new Thread() {                @Override                public void run() {                    for (int j = 0; j < 10000; j++) {                        test.increase();                    }                }                ;            }.start();        }        while (Thread.activeCount() > 1) {  //保证前面的线程都执行完            Thread.yield();        }        System.out.println("inc output:" + test.inc);    }}